#include<bits/stdc++.h>
using namespace std;
int T;
long long n,m,Length,V,det[100005],vis[100005],ans = 0,sum = 0;
struct car{
    double d,v,a,num;
}c[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>Length>>V;
        for(int i = 1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i = 1;i<=m;i++){
            cin>>det[i];
            sum+=det[i];
        }
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=m;j++){
                if(det[j]>=c[i].d){
                    if(sqrt(c[i].v*c[i].v+2*c[i].a*(det[j]-c[i].d))>V){
                        c[i].num++;
                        vis[j]+=det[j];
                    }
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(c[i].num>=1){
                ans++;
            }
        }
        cout<<ans<<" ";
        long long d=0,u=0;
        for(int i = m;i>=0;i--){
            if(vis[i]!=0&&d<sum){
                d += vis[i];
                u++;
            }
        }
        cout<<m-u;
    }
    return 0;
}
